package com.sen.patterns.creational.prototype;

public class TestComplex {

	Complex c1 = new Complex();

	public Complex makeCopy() {
		return (Complex) c1.clone();
	}

	public static void main(String[] args) {
		TestComplex tp = new TestComplex();
		Complex c2 = tp.makeCopy();
		int[] mycopy = c2.getNumbs();
		mycopy[0] = 5;

		System.out.println();
		System.out.print("local array: ");
		for (int i = 0; i < mycopy.length; i++)
			System.out.print(mycopy[i]);
		System.out.println();

		System.out.print("cloned object: ");
		for (int ii = 0; ii < c2.numbs.length; ii++)
			System.out.print(c2.numbs[ii]);
		System.out.println();

		// 原来的对象的属性值也跟着改变了， 这样容易出错，解决方案看Complex2类
		System.out.print("original object: ");
		for (int iii = 0; iii < tp.c1.numbs.length; iii++)
			System.out.print(tp.c1.numbs[iii]);
	}
}